import Vue from 'vue';
import request from './request';
import urls from './RESTFULLURL';

const FUNS: any = {};
function getPropertyValue<T, K extends keyof T>(obj: T, key: K): T[K] {
  return obj[key]
}
type FooType = keyof typeof urls;
Object.keys(urls).forEach((key: string) => {
  FUNS[key] = (options = {}, path = "") => {
    return request(urls[key as FooType] + path, options);
  };
});

// 将services挂载到vue的原型上
// views引用的方法：this.$services.接口名（小驼峰）
Object.defineProperty(Vue.prototype, '$services', { value: FUNS });

export default FUNS;
